package cn.cs.service;

import cn.cs.mapper.AccountDetailMapper;
import cn.cs.pojo.AccountDetail;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@RestController
public class AccountDetailService {

    @Resource
    private AccountDetailMapper accountDetailMapper;

    @RequestMapping(value = "/addAccountDetail", method = RequestMethod.POST)
    public Integer addAccountDetail(@RequestBody AccountDetail accountDetail)throws Exception{
        return accountDetailMapper.insertAccountDetail(accountDetail);
    }

    @RequestMapping(value = "/getAccountDetail", method = RequestMethod.POST)
    public List<AccountDetail> getAccountDetail(@RequestParam("userId") String userId) throws Exception{
        return accountDetailMapper.getAccountDetailByUserId(userId);
    }

    @RequestMapping(value = "/getAccountDetailInvoice", method = RequestMethod.POST)
    public List<AccountDetail> getAccountDetailInvoice(@RequestParam("userId") String userId) throws Exception{
        return accountDetailMapper.getAccountDetailInvoiceByUserId(userId);
    }

    @RequestMapping(value = "/getAccountDetailById", method = RequestMethod.POST)
    public Map<String, Object> getAccountDetailById(@RequestParam("id") String id)throws Exception{
        return accountDetailMapper.getAccountDetailById(id);
    }

    @RequestMapping(value = "/updateAccountStatus", method = RequestMethod.POST)
    public Integer updateAccountStatus(@RequestParam("id") String id, @RequestParam("newAmonut") Double newAmonut)throws Exception{
        return updateAccountStatus(id, newAmonut);
    }

    @RequestMapping(value = "/updateAccountDetailByIds", method = RequestMethod.POST)
    public int updateAccountDetailByIds(@RequestBody String[] params)throws Exception{
        return updateAccountDetailByIds(params);
    }


}
